* Name: README_Stata.do
* Description: Executes all DO files to replicate empirical results in Section 3 of "Distributional Consequences of Policies for Electric Heat Conversion" (Soren Anderson and Justin Kirkpatrick).
* Author: Soren Anderson

* TO REPLICATE: 
* 1. Save the "Code Repository" folder and its contents on your machine. 
* 2. Run "R\1_Preprocess Data.R" using R. [Code will run without this step since the requisite intermediate datasets are already pre-saved in the Data_Proc folder.]
* 3. Replace YOURPATHHERE in the "cd" command below with the filepath leading to "Code Repository" on your machine. No other changes should be necessary. 
* 4. Run this DO file (README_Stata.DO), which will execute a series of DO files tackling specific tasks (see below).


cd "YOURPATHHERE\Code Repository"
clear

log using Stata\recs_analysis.txt, text replace

* MERGE AND CLEAN DATA
	* Input: State_COP_and_HDD.csv, CPI.csv, and RECS.csv from the Data_Proc folder (generated via R code in Step 2).
	* Input: EIA prices and RECS data in CSV/Excel format from the Data_Archive folder.
	* Output: recs_clean.dta to the Data_Proc folder (used in all analysis, tables, and figures below)
do Stata\recs_dataprep.do

* FIGURE 1 (this and all other figures and tables output to the Final_Output folder)
	* fig_price_levels.png
do Stata\recs_prices.do

* FIGURE 2
	* fig_share_vintage_hp.png  [upper-left]
	* fig_share_vintage_elec.png [upper-right]
	* fig_share_vintage_ngas.png [lower-left]
	* fig_share_vintage_kero.png [lower-right]
	* fig_share_vintage_prop.png
	* fig_share_vintage_wood.png
do Stata\recs_retrofitfigs.do

* TABLE 1 (AND TABLE C.1 IN APPENDIX)
	* tab_HeatSharesByRecsVs2009_OldHomes.tex [1a]
	* tab_HeatSharesByRecs_NewHomes_AllRecs.tex [1b]
	* tab_HeatSharesByRecs_OldHomes.tex [C.1a]
	* tab_HeatSharesByRecsVs2009AddControls_OldHomes.tex [C.1b]
do Stata\recs_retrofittabs.do

* FIGURE 3
	* fig_age_cumulative_OLD_AllRECS.png
do Stata\recs_equipage.do

* FIGURE 4 (AND FIGURE C.1 IN APPENDIX)
	* fig_CostScatterOld_Update.png [4]
	* fig_CostScatterOld_NoCovid_Update.png [C.1]
do Stata\recs_pricecorr.do

* TABLES 2-3 (AND TABLES C.2, C.3, AND C.4 IN APPENDIX)
	* tab_OldHeatPumpRegs_Update.tex [2]
	* tab_NewHeatPumpRegs_Update.tex [3]
	* tab_OldHeatPumpRegs_NoCovid_Update.tex [C.2]
	* tab_OldRegs_Update.tex [C.3]
	* tab_NewRegs_Update.tex [C.4]
do Stata\recs_retrofitcorr.do


log close



